home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earcd / grafica / ghostscript / 5.10 / gs_btokn.ps < prev    next >
Text File  |  1997-12-28  |  10KB  |  284 lines

  1. %    Copyright (C) 1994, 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % Initialization file for binary tokens.
  16. % When this is run, systemdict is still writable,
  17. % but everything defined here goes into level2dict.
  18.  
  19. % Define whether or not to allow writing dictionaries.
  20. /WRITEDICTS true def
  21.  
  22. languagelevel 1 .setlanguagelevel
  23. level2dict begin
  24.  
  25. % Initialization for the system name table.
  26.  
  27. mark
  28. % 0
  29.     /abs /add /aload /anchorsearch /and
  30.     /arc /arcn /arct /arcto /array
  31.     /ashow /astore /awidthshow /begin /bind
  32.     /bitshift /ceiling /charpath /clear /cleartomark
  33. % 20
  34.     /clip /clippath /closepath /concat /concatmatrix
  35.     /copy /count /counttomark /currentcmykcolor /currentdash
  36.     /currentdict /currentfile /currentfont /currentgray /currentgstate
  37.     /currenthsbcolor /currentlinecap /currentlinejoin /currentlinewidth /currentmatrix
  38. % 40
  39.     /currentpoint /currentrgbcolor /currentshared /curveto /cvi
  40.     /cvlit /cvn /cvr /cvrs /cvs
  41.     /cvx /def /defineusername /dict /div
  42.     /dtransform /dup /end /eoclip /eofill
  43. % 60
  44.     /eoviewclip /eq /exch /exec /exit
  45.     /file /fill /findfont /flattenpath /floor
  46.     /flush /flushfile /for /forall /ge
  47.     /get /getinterval /grestore /gsave /gstate
  48. % 80
  49.     /gt /identmatrix /idiv /idtransform /if
  50.     /ifelse /image /imagemask /index /ineofill
  51.     /infill /initviewclip /inueofill /inufill /invertmatrix
  52.     /itransform /known /le /length /lineto
  53. % 100
  54.     /load /loop /lt /makefont /matrix
  55.     /maxlength /mod /moveto /mul /ne
  56.     /neg /newpath /not /null /or
  57.     /pathbbox /pathforall /pop /print /printobject
  58. % 120
  59.     /put /putinterval /rcurveto /read /readhexstring
  60.     /readline /readstring /rectclip /rectfill /rectstroke
  61.     /rectviewclip /repeat /restore /rlineto /rmoveto
  62.     /roll /rotate /round /save /scale
  63. % 140
  64.     /scalefont /search /selectfont /setbbox /setcachedevice
  65.     /setcachedevice2 /setcharwidth /setcmykcolor /setdash /setfont
  66.     /setgray /setgstate /sethsbcolor /setlinecap /setlinejoin
  67.     /setlinewidth /setmatrix /setrgbcolor /setshared /shareddict
  68. % 160
  69.     /show /showpage /stop /stopped /store
  70.     /string /stringwidth /stroke /strokepath /sub
  71.     /systemdict /token /transform /translate /truncate
  72.     /type /uappend /ucache /ueofill /ufill
  73. % 180
  74.     /undef /upath /userdict /ustroke /viewclip
  75.     /viewclippath /where /widthshow /write /writehexstring
  76.     /writeobject /writestring /wtranslation /xor /xshow
  77.     /xyshow /yshow /FontDirectory /SharedFontDirectory /Courier
  78. % 200
  79.     /Courier-Bold /Courier-BoldOblique /Courier-Oblique /Helvetica /Helvetica-Bold
  80.     /Helvetica-BoldOblique /Helvetica-Oblique /Symbol /Times-Bold /Times-BoldItalic
  81.     /Times-Italic /Times-Roman /execuserobject /currentcolor /currentcolorspace
  82.     /currentglobal /execform /filter /findresource /globaldict
  83. % 220
  84.     /makepattern /setcolor /setcolorspace /setglobal /setpagedevice
  85.     /setpattern
  86. % pad to 256
  87.     counttomark 256 exch sub { 0 } repeat
  88. % 256
  89.     /= /== /ISOLatin1Encoding /StandardEncoding
  90. % 260
  91.     ([) cvn (]) cvn /atan /banddevice /bytesavailable
  92.     /cachestatus /closefile /colorimage /condition /copypage
  93.     /cos /countdictstack /countexecstack /cshow /currentblackgeneration
  94.     /currentcacheparams /currentcolorscreen /currentcolortransfer /currentcontext /currentflat
  95. % 280
  96.     /currenthalftone /currenthalftonephase /currentmiterlimit /currentobjectformat /currentpacking
  97.     /currentscreen /currentstrokeadjust /currenttransfer /currentundercolorremoval /defaultmatrix
  98.     /definefont /deletefile /detach /deviceinfo /dictstack
  99.     /echo /erasepage /errordict /execstack /executeonly
  100. % 300
  101.     /exp /false /filenameforall /fileposition /fork
  102.     /framedevice /grestoreall /handleerror /initclip /initgraphics
  103.     /initmatrix /instroke /inustroke /join /kshow
  104.     /ln /lock /log /mark /monitor
  105. % 320
  106.     /noaccess /notify /nulldevice /packedarray /quit
  107.     /rand /rcheck /readonly /realtime /renamefile
  108.     /renderbands /resetfile /reversepath /rootfont /rrand
  109.     /run /scheck /setblackgeneration /setcachelimit /setcacheparams
  110. % 340
  111.     /setcolorscreen /setcolortransfer /setfileposition /setflat /sethalftone
  112.     /sethalftonephase /setmiterlimit /setobjectformat /setpacking /setscreen
  113.     /setstrokeadjust /settransfer /setucacheparams /setundercolorremoval /sin
  114.     /sqrt /srand /stack /status /statusdict
  115. % 360
  116.     /true /ucachestatus /undefinefont /usertime /ustrokepath
  117.     /version /vmreclaim /vmstatus /wait /wcheck
  118.     /xcheck /yield /defineuserobject /undefineuserobject /UserObjects
  119.     /cleardictstack
  120. % 376
  121.     /A /B /C /D /E /F /G /H /I /J /K /L /M
  122.     /N /O /P /Q /R /S /T /U /V /W /X /Y /Z
  123.     /a /b /c /d /e /f /g /h /i /j /k /l /m
  124.     /n /o /p /q /r /s /t /u /v /w /x /y /z
  125. % 428
  126.     /setvmthreshold (<<) cvn
  127.     (>>) cvn /currentcolorrendering /currentdevparams /currentoverprint /currentpagedevice
  128.     /currentsystemparams /currentuserparams /defineresource /findencoding /gcheck
  129. % 440
  130.     /glyphshow /languagelevel /product /pstack /resourceforall
  131.     /resourcestatus /revision /serialnumber /setcolorrendering /setdevparams
  132.     /setoverprint /setsystemparams /setuserparams /startjob /undefineresource
  133.     /GlobalFontDirectory /ASCII85Decode /ASCII85Encode /ASCIIHexDecode /ASCIIHexEncode
  134. % 460
  135.     /CCITTFaxDecode /CCITTFaxEncode /DCTDecode /DCTEncode /LZWDecode
  136.     /LZWEncode /NullEncode /RunLengthDecode /RunLengthEncode /SubFileDecode
  137.     /CIEBasedA /CIEBasedABC /DeviceCMYK /DeviceGray /DeviceRGB
  138.     /Indexed /Pattern /Separation
  139. % 478 -- end
  140. .packtomark
  141. dup /SystemNames exch def .installsystemnames
  142.  
  143. % Define printobject and writeobject.
  144. % These are mostly implemented in PostScript, so that we don't have to
  145. % worry about interrupts or callbacks when writing to the output file.
  146.  
  147. % Define procedures for accumulating the space required to represent
  148. % an object in binary form.
  149. /cntdict mark        % <#refs> <#chars> <obj> -proc- <#refs> <#chars>
  150.     /integertype /pop load
  151.     /realtype 1 index
  152.     /marktype 1 index
  153.     /nulltype 1 index
  154.     /booleantype 1 index
  155.     /nametype { length add } bind
  156.     /stringtype 1 index
  157.     /arraytype null
  158.     WRITEDICTS { /dicttype null } if
  159. .dicttomark def
  160. cntdict /arraytype
  161.  { dup dup length 5 -1 roll add 4 2 roll
  162.     { dup type //cntdict exch get exec } forall
  163.  } bind put
  164. WRITEDICTS
  165.  { cntdict /dicttype
  166.     { dup dup length 2 mul 5 -1 roll add 4 2 roll
  167.        { 4 1 roll dup type //cntdict exch get exec
  168.      3 -1 roll dup type //cntdict exch get exec
  169.        } forall
  170.     } bind put
  171.  } if
  172.  
  173. /w2dict mark
  174.     /nametype { 2 copy .writecvs pop } bind
  175.     /stringtype 1 index
  176. .dicttomark def
  177.  
  178. /.writeobjects        % <file> <tag> <array> .writeobjects -
  179.  {
  180.     mark exch
  181.  
  182.     % Count the space required for refs and strings.
  183.     dup length 0 3 -1 roll
  184.     % Stack: <file> <tag> -mark- <#refs> <#chars> <array>
  185.  
  186.     dup 4 1 roll
  187.      { dup type //cntdict exch get exec
  188.      } forall
  189.  
  190.     % Write the header.
  191.     % Stack: <file> <tag> -mark- <array1> ... <array|dictN> <#refs> <#chars>
  192.     counttomark 3 add -2 roll 4 1 roll
  193.     % Stack: -mark- <array1> ... <array|dictN> <tag> <#refs> <#chars> <file>
  194.     dup counttomark 1 sub index length
  195.     4 index 3 bitshift 4 index add
  196.     (xxxxxxxx) .bosheader writestring
  197.  
  198.     % Write the objects per se.
  199.     3 1 roll pop
  200.     counttomark 1 sub index length 3 bitshift exch
  201.     3 bitshift
  202.     % Stack: -mark- <array1> ... <array|dictN> <tag> <file> <ref#> <char#>
  203.  
  204.     counttomark 4 sub
  205.      { counttomark -1 roll dup 6 1 roll
  206.        dup type /dicttype eq        % can't be first object
  207.         {  { 5 1 roll (xxxxxxxx) .bosobject
  208.          3 index exch writestring
  209.          4 -1 roll (xxxxxxxx) .bosobject
  210.          3 index exch writestring
  211.            } forall
  212.         }
  213.         {  { (xxxxxxxx) .bosobject
  214.          dup 1 6 index put
  215.          3 index exch writestring
  216.          4 -1 roll pop 0 4 1 roll    % clear tag
  217.            } forall
  218.         }
  219.        ifelse
  220.      }
  221.     repeat
  222.  
  223.     % Write the strings and names.
  224.     pop pop exch pop
  225.     % Stack: -mark- <array1> ... <array|dictN> <file>
  226.  
  227.      counttomark 1 sub
  228.      { counttomark -1 roll
  229.         {        % The counting pass ensured that the keys and values
  230.             % of any dictionary must be writable objects.
  231.             % Hence, we are processing a dictionary iff
  232.             % the next-to-top stack element is not a file.
  233.           1 index type /filetype ne
  234.            { exch 2 index exch dup type //w2dict exch .knownget
  235.           { exec } { pop } ifelse pop
  236.            }
  237.           if
  238.               dup type //w2dict exch .knownget { exec } { pop } ifelse
  239.         } forall
  240.      }
  241.     repeat
  242.  
  243.     % Clean up.
  244.     % Stack: -mark- <file>
  245.  
  246.     pop pop
  247.  
  248.  } odef
  249. currentdict /cntdict .undef
  250. currentdict /w2dict .undef
  251.  
  252. /printobject {        % <obj> <tag> printobject -
  253.   (%stdout) (w) file 2 index 2 index writeobject pop pop
  254. } odef
  255. /writeobject {        % <file> <obj> <tag> writeobject -
  256.   3 copy exch
  257.         % We must allocate the array in local VM
  258.         % to avoid a possible invalidaccess.
  259.   .currentglobal false .setglobal exch 1 array astore exch .setglobal
  260.   .writeobjects pop pop pop
  261. } odef
  262.  
  263. % Implement binary error message output.
  264.   /.printerror
  265.    { $error /binary get .languagelevel 2 eq and
  266.       { currentobjectformat 0 ne
  267.          { [ /Error $error /errorname get $error /command get false
  268.        ] 250 printobject
  269.      }
  270.      //.printerror
  271.     ifelse
  272.       }
  273.       //.printerror
  274.      ifelse
  275.    } bind def
  276.  
  277. % End of level2dict
  278.  
  279. end
  280. .setlanguagelevel
  281.